import { forwardRef, useMemo } from 'react';
import { Tabs } from 'antd'
import Log from './components/index';
import './style.less';
import { TextWidget } from '@inbiz/react';

export interface IProps {
  pagesNum: any;
  puredynamicdata: any;
}

const LogManagement = (props: IProps, ref: any) => {
  const { pagesNum, puredynamicdata } = props


  // 展示几项
  const showItems = useMemo(() => puredynamicdata.filter(item => item.hide !== true), [puredynamicdata])


  return (
    <div className="inbiz-log-management-component"
    >

      {showItems?.length === 1 ?
        <Log
          tabskey={showItems[0].id}
          pagesNum={pagesNum}
        />
        : <Tabs>
          {showItems.map((item: any) => {
            return <Tabs.TabPane tab={<TextWidget>{item.title}</TextWidget>} key={item.id}>
              <Log
                tabskey={item.id}
                pagesNum={pagesNum}
              />
            </Tabs.TabPane>
          })}
        </Tabs>

      }
    </div >
  );
}

export default forwardRef(LogManagement);
